package com.mrstage.ndkplayer;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.mrstage.ndkplayer.databinding.ActivityWelcomeBinding;

import java.util.List;

public class WelcomeActivity extends AppCompatActivity {

    private ActivityWelcomeBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityWelcomeBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        initView();
    }

    private void initView() {
        binding.openPlayer.setOnClickListener((v)->{
            XXPermissions.with(WelcomeActivity.this)
                    .permission(Permission.WRITE_EXTERNAL_STORAGE)
                    .permission(Permission.READ_EXTERNAL_STORAGE)
                    .request((permissions, all) -> {
                        if (all){
                            startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
                        }else {
                            Toast.makeText(WelcomeActivity.this,"不开权限，玩个灯啊",Toast.LENGTH_SHORT).show();
                        }
                    });
        });
    }
}
